<?xml version="1.0"?>

<f:view
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component"
	xmlns:ace="http://www.icefaces.org/icefaces/components"
	xmlns:icecore="http://www.icefaces.org/icefaces/core"
	xmlns:liferay-ui="http://portletfaces.org/liferayfaces/liferay-ui"
	xmlns:liferay-util="http://portletfaces.org/liferayfaces/liferay-util"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:portlet="http://java.sun.com/portlet_2_0" 
>
<portlet:defineObjects />
	<h:head />
	<h:body>
	<ice:form id="platoForm" enctype="multipart/form-data">
		<ice:panelGrid columns="2">
			<ice:panelGrid id="imagenPanel">
				<ice:panelGrid rendered="#{platoBean.image != null}">
					<img src="#{platoBean.srcImagen}" name="imagen" id="image" alt="#{platoBean.imagen}" title="#{platoBean.imagen}" />
				</ice:panelGrid>
			</ice:panelGrid>
			<ice:panelGrid id="plato" columns="4">
				
				<ice:outputText id="active" value="#{i18n['active']}"/>
				<ice:selectBooleanCheckbox id="activeIn" value="#{platoBean.plato.activo}"/>
				<ice:outputText id="tipo" value="#{i18n['type']}"/>
				<ice:selectOneMenu id="tipoIn" value="#{platoBean.plato.tipoId}">
					<f:selectItems value="#{platoBean.tipos}"/>
				</ice:selectOneMenu>
				<ice:outputText id="precio" value="#{i18n['price']}"/>
				<ice:inputText id="precioIn" value="#{platoBean.plato.precio}"/>
				<ice:outputText id="imagen" value="#{i18n['image']}"/>
				<ice:panelGrid columns="2">
					<ace:fileEntry id="file" label="#{i18n['examinar']}" relativePath="/images" useOriginalFilename="true" useSessionSubdir="true" fileEntryListener="#{platoBean.sampleListener}" immediate="true">
		                 <ice:commandButton id="cargar" value="#{i18n['btn_cargar']}" styleClass="buttonStyleCargar" style="vertical-align: top;display: none;">
			               	<f:ajax render="@all"/>
			             </ice:commandButton>
			        </ace:fileEntry>
			        <ice:commandButton id="subir" value="#{i18n['btn_guardar']}" onclick="document.getElementById('cargar').click">
			        	<f:ajax render="@all" />
			        </ice:commandButton>
				</ice:panelGrid>
			</ice:panelGrid>
		</ice:panelGrid>
	</ice:form>
	<h:form id="idiomaForm">
		<ice:panelGrid id="lenguajePlato">
			<ice:dataTable id="languages" var="language" value="#{platoBean.languagesElement}" rendered="#{platoBean.languagesElement.size() > 0}" width="300px">
				<ice:column styleClass="language.estilo">						
					<ice:rowSelector selectionListener="#{tipoBean.selectionListener}">
						<ice:panelGrid columns="5">								
							<ice:outputText value="#{i18n['language']}" />	
							<ice:selectOneMenu value="#{language.language}" partialSubmit="true" valueChangeListener="#{platoBean.checkLanguage}" >
								<f:selectItems value="#{platoBean.languages}" />
							</ice:selectOneMenu>
							<ice:outputText value="#{i18n['name']}" />
							<ice:inputText size="25" maxlength="50" partialSubmit="true" value="#{language.name}"/>
						</ice:panelGrid>
						<ice:panelGrid columns="2">
							<ice:outputText value="#{i18n['description']}" />
							<ice:inputTextarea rows="2" cols="25" maxlength="250" partialSubmit="true" value="#{language.description}"/>								
						</ice:panelGrid>
					</ice:rowSelector>													
				</ice:column>				
			</ice:dataTable>
			<h:panelGrid columns="2">
				<h:commandButton id="add" value="#{i18n['add']}" action="#{platoBean.addLanguage()}" >
					<f:ajax render="@form"/>
				</h:commandButton>
				<h:commandButton id="less" value="#{i18n['delete']}" action="#{platoBean.lessLanguage()}" >
					<f:ajax render="@form"/>
				</h:commandButton>
			</h:panelGrid>
		</ice:panelGrid>
		
		<h:commandButton id="agree" value="#{i18n['agree']}" action="#{platoBean.savePlato()}">
			<f:ajax render="@form"/>
		</h:commandButton>
		<h:commandButton id="cancel" value="#{i18n['cancel']}" action="#{platoBean.doCancel()}">
			<f:ajax render="@form"/>
		</h:commandButton>
			
	</h:form>
	</h:body>
</f:view>